<?php
declare (strict_types = 1);

namespace app\middleware\backend;

use Closure;
use think\Request;
use think\Response;

class AuthMiddleware
{
    /**
     * 处理请求
     *
     * @param Request $request
     * @param Closure $next
     * @return Response
     */
    public function handle($request, Closure $next)
    {
        $admin = auth('backend')->userOrFail();
        $request->withMiddleware(['admin' => $admin]);
        return $next($request);
    }
}
